package leetcode.code0318;

public class Solution2 extends Solution318 {

	private final int RANGE = 0b11111111111111111111111111;

	@Override
	public int maxProduct(String[] words) {
		int len = words.length;
		int[] words1 = new int[len];
		for (int i = 0; i < len; i++) {
			words1[i] = this.word2int(words[i]);// string 转 int
		}
		int max = 0;
		for (int i = len - 1; i > 0; i--) {
			for (int j = i - 1; j >= 0; j--) {
				if ((words1[i] & words1[j]) == 0) {// 没有相同字符
					max = Math.max(max, words[i].length() * words[j].length());
				}
			}
		}
		return max;
	}

	private int word2int(String word) {
		int ans = 0;
		char[] chars = word.toCharArray();
		for (char c : chars) {
			ans |= 1 << (c - 'a');
		}
		return ans;
	}

	public static void main(String[] args) {
		Solution2 so = new Solution2();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
		System.out.println(Integer.toBinaryString(4194311));
	}

}
